package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/10/22 2:29
 */
@RestController
@RequestMapping("/admin/product")
public class BaseTrademarkController {
    @Autowired
    private BaseTrademarkService baseTrademarkService;

    ///admin/product/baseTrademark/1/10
    @GetMapping("/baseTrademark/{page}/{limit}")
    public Result baseTrademarkList(@PathVariable("page") Long page,@PathVariable("limit") Long limit){
        //分页查询
        Page<BaseTrademark> baseTrademarkPage = new Page<>(page, limit);
        baseTrademarkService.page(baseTrademarkPage);
        return Result.ok(baseTrademarkPage);
    }
    ///baseTrademark/get/26
    @GetMapping("/baseTrademark/get/{id}")
    public Result baseTrademarkGet(@PathVariable("id") Long id){
        BaseTrademark baseTrademark = baseTrademarkService.getById(id);
        return Result.ok(baseTrademark);
    }
    //baseTrademark/update
    @PutMapping("/baseTrademark/update")
    public Result baseTrademarkUpdate(@RequestBody BaseTrademark baseTrademark){
        baseTrademarkService.updateById(baseTrademark);
        return Result.ok();
    }
    ///baseTrademark/remove/17
    @DeleteMapping("/baseTrademark/remove/{id}")
    public Result baseTrademarkRemove(@PathVariable("id") Long id){
        baseTrademarkService.removeById(id);
        return Result.ok();
    }
    ///baseTrademark/save
    @PostMapping("/baseTrademark/save")
    public Result baseTrademarkSave(@RequestBody BaseTrademark baseTrademark){
        baseTrademarkService.save(baseTrademark);
        return Result.ok();
    }
}
